import jwt from "jsonwebtoken";
import md5 from "md5";

const SECRET_KEY = md5(process.env.Y_JWT_SECRET_KEY!);

export class JWTHelper {
  /**
   * 创建JWT
   */
  public static createJwt(data = {}, remember = 1) {
    return jwt.sign(data, SECRET_KEY, { expiresIn: 60 * 60 * 24 * remember });
  }

  /**
   * 验证token
   */
  public static verify(token: string) {
    return jwt.verify(token, SECRET_KEY);
  }
}
